
// import TableList from "@components/templates/tablelist";
import TableList from "@components/templates/customtablelist";
import { HttpFinanceFrozen, HttpUnfrozenFinance } from '@/service/api/views'
import { mapState,mapGetters } from "vuex";
import compAdd from './add';
export default {
    mixins: [TableList],
    components: {
        compAdd,
    },
    data() {
        return {
            // totals: 0,
            isMixin: true,
            Tools: {show: true},
            Tabs: {show: true},
            formData:{
                search:{
                }
            },
            Searchs: {
                show: true,
                labelWidth: 120,
            },
            Plugins: {show: true},
            
            totalnum:'',
        }
    },
    methods: {
        ajaxRequest: HttpFinanceFrozen,
        interceptRequest(params){
            if(params.search.BT_freezeDate&&params.search.BT_freezeDate[0]!=''){
                params.search.BT_freezeDate = this.handleDateFormat(params.search.BT_freezeDate[0],'yyyy-mm-dd') + ' ~ ' +this.handleDateFormat(params.search.BT_freezeDate[1],'yyyy-mm-dd')
            }
            if(params.search.BT_unfreezeDate&&params.search.BT_unfreezeDate[0]!=''){
                params.search.BT_unfreezeDate = this.handleDateFormat(params.search.BT_unfreezeDate[0],'yyyy-mm-dd') + ' ~ ' +this.handleDateFormat(params.search.BT_unfreezeDate[1],'yyyy-mm-dd')
            }
            return params
        },
        handleOperates(params="", type,batch) {
            if(batch===true){
                params=(params||this.checkedData.join(','))+'';
                if(!params.length) return this.$Message.warning('请选择至少一条数据');
            }
            switch (type) {
                case 'add':
                    this.operate = {
                        show: true,
                        component: "compAdd",
                        title: "添加",
                        width: 660,
                        id:params,
                        type,
                        showFooter: false
                    }
                    break;
                case 'unfrozen':
                    this.operate = {
                        show: true,
                        alert: "primary",
                        params: { ids: params },
                        title: "账户解冻",
                        ajaxRequest: HttpUnfrozenFinance
                    }
                    break;
                case 'download':
                    this.handleWebfs(
                        process.env.VUE_APP_APIURL_SHIP + "/api/jwt/spl/freeze/export",{},
                        "download"
                    );
                    break;
                
            }
        },
    },
    computed: {
        ...mapGetters('dictionary',['getSysAllList']),
        TabsData(){
            return [
                {
                    name: this.$ct('global.common.all',{defaultValue:'全部'}),
                    key:'EQ_status',
                    val: null
                }, {
                    name: '冻结',
                    key:'EQ_status',
                    val: "0"
                }, {
                    name: '解冻',
                    key:'EQ_status',
                    val: "1"
                }
            ]
        },
        // 搜索下拉框展示内容
        SearchsData() {
            return  [
                {
                    label: '组织',
                    tag: 'Select',
                    key: 'EQ_organizationId',
                    options:this.getSysAllList,
                    props:{
                        filterable:true,
                    },
                    show:true,
                },
                {
                    label: '冻结日期',
                    tag: 'DatePicker',
                    key: 'BT_freezeDate',
                    props:{
                        options:this.options,
                        type:'daterange',
                    },
                    // hideSearchTip:true,
                    style: "width:200px",
                    show:true,
                },
                {
                    label: '解冻日期',
                    tag: 'DatePicker',
                    key: 'BT_unfreezeDate',
                    props:{
                        options:this.options,
                        type:'daterange',
                    },
                    // hideSearchTip:true,
                    style: "width:200px",
                    show:true,
                },
            ]
        },
        ToolsData(){
            return [
                {
                    name: "添加",
                    theme: 'primary',
                    operate: 'add',
                },
                {
                    name: "解冻",
                    theme: 'info',
                    operate: 'unfrozen',
                    batch:true,
                },
                {
                    name: "导出",
                    theme: 'success',
                    operate: 'download',
                },
            ]
        },
        // table的展示数据
        columns() {
            return [{
                title: "#",
                type: 'selection',
                width: 70
            }, {
                title: "账户组织",
                key: "organizationId",
                render: (h, { row }) => {
                    const id = row.organizationId;
                    const orgitem = this.getSysAllList.filter((item) => {
                        return id == item.value
                    })[0] || {};
                    return <div>
                        <div><span>{orgitem.label}</span></div>
                    </div>
                },
                sortable: true,
            }, {
                title: "金额",
                key: "amount",
            }, {
                title: "冻结原因",
                key: "cause",
            }, {
                title: "状态",
                key: "status",
                sortable: true,
                render: (h, { row }) => {
                    return <div>
                        <Tag type="border" v-show={row.status === 0} color="success">冻结</Tag>
                        <Tag type="border" v-show={row.status === 1} color="error">解冻</Tag>
                    </div>
                }
            }, {
                title: "冻结时间",
                key: "freezeDate",
                sortable: true,
            }, {
                title: "解冻时间",
                key: "unfreezeDate",
            },];
        },
        
    },

};
